<?php
/**
 *
 * @author andrew carlson <andrew@acstudiosllc.com>
 * @version 0.0.1
 * @copyright 2012 ACStudios LLC
 * @package default
 */

namespace Encompass\Core;

/**
 * Encompass core controller class
 *
 * @package default
 * @author  andrew carlson <andrew@acstudiosllc.com>
 */
class coreController {

	/**
	 * setup the environment, load in classes and route by action
	 */
	function __construct() {
		// if an action is present, we need to route to there
		$action = \Encompass\Utilities\utilities::actionRoute();
		$this->$action();
	}
	
	/**
	 * default view for now until I can build out a view class
	 */
	function grid() {
		$loader = new \Twig_Loader_Filesystem('templates/');

		if (CACHING) {
			$twig = new \Twig_Environment($loader, array('cache' => 'tmp/cache'));
		} else {
			$twig = new \Twig_Environment($loader);
		}

		$template = $twig->loadTemplate('index.tpl');
		
		echo $template->render(array(
			'pageTitle' => 'Encompass Home'
		));
	}

	/**
	 * handle user accounts
	 */
	public function public_Accounts() {	
	}

	/**
	 * handle permissions
	 */
	public function public_Permissions() {
	}

	/**
	 * handle settings
	 */
	public function public_Settings() {
	}
	
	function getMenu() {
		$menu = \Encompass\Utilities\utilities::buildMenus(get_class_methods($this));
		echo json_encode($menu);
	}

}
?>
